/**
 * <copyright>
 * </copyright>
 *
 * 
 */
package OrchestrationLanguage.resource.ol.mopp;

public class OlPrinter implements OrchestrationLanguage.resource.ol.IOlTextPrinter {
	
	protected OrchestrationLanguage.resource.ol.IOlTokenResolverFactory tokenResolverFactory = new OrchestrationLanguage.resource.ol.mopp.OlTokenResolverFactory();
	
	protected java.io.OutputStream outputStream;
	
	/**
	 * Holds the resource that is associated with this printer. This may be null if
	 * the printer is used stand alone.
	 */
	private OrchestrationLanguage.resource.ol.IOlTextResource resource;
	
	private java.util.Map<?, ?> options;
	
	public OlPrinter(java.io.OutputStream outputStream, OrchestrationLanguage.resource.ol.IOlTextResource resource) {
		super();
		this.outputStream = outputStream;
		this.resource = resource;
	}
	
	protected int matchCount(java.util.Map<String, Integer> featureCounter, java.util.Collection<String> needed) {
		int pos = 0;
		int neg = 0;
		
		for (String featureName : featureCounter.keySet()) {
			if (needed.contains(featureName)) {
				int value = featureCounter.get(featureName);
				if (value == 0) {
					neg += 1;
				} else {
					pos += 1;
				}
			}
		}
		return neg > 0 ? -neg : pos;
	}
	
	protected void doPrint(org.eclipse.emf.ecore.EObject element, java.io.PrintWriter out, String globaltab) {
		if (element == null) {
			throw new java.lang.IllegalArgumentException("Nothing to write.");
		}
		if (out == null) {
			throw new java.lang.IllegalArgumentException("Nothing to write on.");
		}
		
		if (element instanceof OrchestrationLanguage.Variable_Assignment) {
			print_OrchestrationLanguage_Variable_005fAssignment((OrchestrationLanguage.Variable_Assignment) element, globaltab, out);
			return;
		}
		if (element instanceof OrchestrationLanguage.Variable_Declaration) {
			print_OrchestrationLanguage_Variable_005fDeclaration((OrchestrationLanguage.Variable_Declaration) element, globaltab, out);
			return;
		}
		if (element instanceof OrchestrationLanguage.Variable) {
			print_OrchestrationLanguage_Variable((OrchestrationLanguage.Variable) element, globaltab, out);
			return;
		}
		if (element instanceof OrchestrationLanguage.Modules) {
			print_OrchestrationLanguage_Modules((OrchestrationLanguage.Modules) element, globaltab, out);
			return;
		}
		if (element instanceof OrchestrationLanguage.Module) {
			print_OrchestrationLanguage_Module((OrchestrationLanguage.Module) element, globaltab, out);
			return;
		}
		if (element instanceof OrchestrationLanguage.Import) {
			print_OrchestrationLanguage_Import((OrchestrationLanguage.Import) element, globaltab, out);
			return;
		}
		if (element instanceof OrchestrationLanguage.ExternalServices) {
			print_OrchestrationLanguage_ExternalServices((OrchestrationLanguage.ExternalServices) element, globaltab, out);
			return;
		}
		if (element instanceof OrchestrationLanguage.InternalServices) {
			print_OrchestrationLanguage_InternalServices((OrchestrationLanguage.InternalServices) element, globaltab, out);
			return;
		}
		if (element instanceof OrchestrationLanguage.Main) {
			print_OrchestrationLanguage_Main((OrchestrationLanguage.Main) element, globaltab, out);
			return;
		}
		if (element instanceof OrchestrationLanguage.InternalProcess) {
			print_OrchestrationLanguage_InternalProcess((OrchestrationLanguage.InternalProcess) element, globaltab, out);
			return;
		}
		if (element instanceof OrchestrationLanguage.Call) {
			print_OrchestrationLanguage_Call((OrchestrationLanguage.Call) element, globaltab, out);
			return;
		}
		if (element instanceof OrchestrationLanguage.Argument) {
			print_OrchestrationLanguage_Argument((OrchestrationLanguage.Argument) element, globaltab, out);
			return;
		}
		if (element instanceof OrchestrationLanguage.If) {
			print_OrchestrationLanguage_If((OrchestrationLanguage.If) element, globaltab, out);
			return;
		}
		if (element instanceof OrchestrationLanguage.Else) {
			print_OrchestrationLanguage_Else((OrchestrationLanguage.Else) element, globaltab, out);
			return;
		}
		if (element instanceof OrchestrationLanguage.Process) {
			print_OrchestrationLanguage_Process((OrchestrationLanguage.Process) element, globaltab, out);
			return;
		}
		
		addWarningToResource("The printer can not handle " + element.eClass().getName() + " elements", element);
	}
	
	protected OrchestrationLanguage.resource.ol.mopp.OlReferenceResolverSwitch getReferenceResolverSwitch() {
		return (OrchestrationLanguage.resource.ol.mopp.OlReferenceResolverSwitch) new OrchestrationLanguage.resource.ol.mopp.OlMetaInformation().getReferenceResolverSwitch();
	}
	
	protected void addWarningToResource(final String errorMessage, org.eclipse.emf.ecore.EObject cause) {
		OrchestrationLanguage.resource.ol.IOlTextResource resource = getResource();
		if (resource == null) {
			// the resource can be null if the printer is used stand alone
			return;
		}
		resource.addProblem(new OrchestrationLanguage.resource.ol.mopp.OlProblem(errorMessage, OrchestrationLanguage.resource.ol.OlEProblemType.PRINT_PROBLEM, OrchestrationLanguage.resource.ol.OlEProblemSeverity.WARNING), cause);
	}
	
	public void setOptions(java.util.Map<?,?> options) {
		this.options = options;
	}
	
	public java.util.Map<?,?> getOptions() {
		return options;
	}
	
	public OrchestrationLanguage.resource.ol.IOlTextResource getResource() {
		return resource;
	}
	
	/**
	 * Calls {@link #doPrint(EObject, PrintWriter, String)} and writes the result to
	 * the underlying output stream.
	 */
	public void print(org.eclipse.emf.ecore.EObject element) {
		java.io.PrintWriter out = new java.io.PrintWriter(new java.io.BufferedOutputStream(outputStream));
		doPrint(element, out, "");
		out.flush();
		out.close();
	}
	
	public void print_OrchestrationLanguage_Variable_005fAssignment(OrchestrationLanguage.Variable_Assignment element, String outertab, java.io.PrintWriter out) {
		String localtab = outertab;
		// The printCountingMap contains a mapping from feature names to the number of
		// remaining elements that still need to be printed. The map is initialized with
		// the number of elements stored in each structural feature. For lists this is the
		// list size. For non-multiple features it is either 1 (if the feature is set) or
		// 0 (if the feature is null).
		java.util.Map<String, Integer> printCountingMap = new java.util.LinkedHashMap<String, Integer>(1);
		Object temp;
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.VARIABLE_ASSIGNMENT__ASSIGN));
		printCountingMap.put("assign", temp == null ? 0 : 1);
		// print collected hidden tokens
		boolean iterate = true;
		java.io.StringWriter sWriter = null;
		java.io.PrintWriter out1 = null;
		java.util.Map<String, Integer> printCountingMap1 = null;
		// DEFINITION PART BEGINS (CsString)
		out.print("Variable_Assignment");
		out.print(" ");
		// DEFINITION PART BEGINS (CsString)
		out.print("{");
		out.print(" ");
		// DEFINITION PART BEGINS (CompoundDefinition)
		iterate = true;
		while (iterate) {
			sWriter = new java.io.StringWriter();
			out1 = new java.io.PrintWriter(sWriter);
			printCountingMap1 = new java.util.LinkedHashMap<String, Integer>(printCountingMap);
			print_OrchestrationLanguage_Variable_005fAssignment_0(element, localtab, out1, printCountingMap1);
			if (printCountingMap.equals(printCountingMap1)) {
				iterate = false;
				out1.close();
			} else {
				out1.flush();
				out1.close();
				out.print(sWriter.toString());
				printCountingMap.putAll(printCountingMap1);
			}
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("}");
		out.print(" ");
	}
	
	public void print_OrchestrationLanguage_Variable_005fAssignment_0(OrchestrationLanguage.Variable_Assignment element, String outertab, java.io.PrintWriter out, java.util.Map<String, Integer> printCountingMap) {
		int count;
		// DEFINITION PART BEGINS (CsString)
		out.print("assign");
		out.print(" ");
		// DEFINITION PART BEGINS (CsString)
		out.print(":");
		out.print(" ");
		// DEFINITION PART BEGINS (PlaceholderUsingDefaultToken)
		count = printCountingMap.get("assign");
		if (count > 0) {
			Object o = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.VARIABLE_ASSIGNMENT__ASSIGN));
			if (o != null) {
				OrchestrationLanguage.resource.ol.IOlTokenResolver resolver = tokenResolverFactory.createTokenResolver("TEXT");
				resolver.setOptions(getOptions());
				out.print(resolver.deResolve(getReferenceResolverSwitch() == null ? null : getReferenceResolverSwitch().getVariable_AssignmentAssignReferenceResolver().deResolve((OrchestrationLanguage.Variable) o, element, (org.eclipse.emf.ecore.EReference) element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.VARIABLE_ASSIGNMENT__ASSIGN)), element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.VARIABLE_ASSIGNMENT__ASSIGN), element));
				out.print(" ");
			}
			printCountingMap.put("assign", count - 1);
		}
	}
	
	
	public void print_OrchestrationLanguage_Variable_005fDeclaration(OrchestrationLanguage.Variable_Declaration element, String outertab, java.io.PrintWriter out) {
		String localtab = outertab;
		// The printCountingMap contains a mapping from feature names to the number of
		// remaining elements that still need to be printed. The map is initialized with
		// the number of elements stored in each structural feature. For lists this is the
		// list size. For non-multiple features it is either 1 (if the feature is set) or
		// 0 (if the feature is null).
		java.util.Map<String, Integer> printCountingMap = new java.util.LinkedHashMap<String, Integer>(1);
		Object temp;
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.VARIABLE_DECLARATION__DECLARE));
		printCountingMap.put("declare", temp == null ? 0 : 1);
		// print collected hidden tokens
		boolean iterate = true;
		java.io.StringWriter sWriter = null;
		java.io.PrintWriter out1 = null;
		java.util.Map<String, Integer> printCountingMap1 = null;
		// DEFINITION PART BEGINS (CsString)
		out.print("Variable_Declaration");
		out.print(" ");
		// DEFINITION PART BEGINS (CsString)
		out.print("{");
		out.print(" ");
		// DEFINITION PART BEGINS (CompoundDefinition)
		iterate = true;
		while (iterate) {
			sWriter = new java.io.StringWriter();
			out1 = new java.io.PrintWriter(sWriter);
			printCountingMap1 = new java.util.LinkedHashMap<String, Integer>(printCountingMap);
			print_OrchestrationLanguage_Variable_005fDeclaration_0(element, localtab, out1, printCountingMap1);
			if (printCountingMap.equals(printCountingMap1)) {
				iterate = false;
				out1.close();
			} else {
				out1.flush();
				out1.close();
				out.print(sWriter.toString());
				printCountingMap.putAll(printCountingMap1);
			}
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("}");
		out.print(" ");
	}
	
	public void print_OrchestrationLanguage_Variable_005fDeclaration_0(OrchestrationLanguage.Variable_Declaration element, String outertab, java.io.PrintWriter out, java.util.Map<String, Integer> printCountingMap) {
		int count;
		// DEFINITION PART BEGINS (CsString)
		out.print("declare");
		out.print(" ");
		// DEFINITION PART BEGINS (CsString)
		out.print(":");
		out.print(" ");
		// DEFINITION PART BEGINS (PlaceholderUsingDefaultToken)
		count = printCountingMap.get("declare");
		if (count > 0) {
			Object o = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.VARIABLE_DECLARATION__DECLARE));
			if (o != null) {
				OrchestrationLanguage.resource.ol.IOlTokenResolver resolver = tokenResolverFactory.createTokenResolver("TEXT");
				resolver.setOptions(getOptions());
				out.print(resolver.deResolve(getReferenceResolverSwitch() == null ? null : getReferenceResolverSwitch().getVariable_DeclarationDeclareReferenceResolver().deResolve((OrchestrationLanguage.Variable) o, element, (org.eclipse.emf.ecore.EReference) element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.VARIABLE_DECLARATION__DECLARE)), element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.VARIABLE_DECLARATION__DECLARE), element));
				out.print(" ");
			}
			printCountingMap.put("declare", count - 1);
		}
	}
	
	
	public void print_OrchestrationLanguage_Variable(OrchestrationLanguage.Variable element, String outertab, java.io.PrintWriter out) {
		String localtab = outertab;
		// The printCountingMap contains a mapping from feature names to the number of
		// remaining elements that still need to be printed. The map is initialized with
		// the number of elements stored in each structural feature. For lists this is the
		// list size. For non-multiple features it is either 1 (if the feature is set) or
		// 0 (if the feature is null).
		java.util.Map<String, Integer> printCountingMap = new java.util.LinkedHashMap<String, Integer>(1);
		Object temp;
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.VARIABLE__NAME));
		printCountingMap.put("name", temp == null ? 0 : 1);
		// print collected hidden tokens
		boolean iterate = true;
		java.io.StringWriter sWriter = null;
		java.io.PrintWriter out1 = null;
		java.util.Map<String, Integer> printCountingMap1 = null;
		// DEFINITION PART BEGINS (CsString)
		out.print("Variable");
		out.print(" ");
		// DEFINITION PART BEGINS (CsString)
		out.print("{");
		out.print(" ");
		// DEFINITION PART BEGINS (CompoundDefinition)
		iterate = true;
		while (iterate) {
			sWriter = new java.io.StringWriter();
			out1 = new java.io.PrintWriter(sWriter);
			printCountingMap1 = new java.util.LinkedHashMap<String, Integer>(printCountingMap);
			print_OrchestrationLanguage_Variable_0(element, localtab, out1, printCountingMap1);
			if (printCountingMap.equals(printCountingMap1)) {
				iterate = false;
				out1.close();
			} else {
				out1.flush();
				out1.close();
				out.print(sWriter.toString());
				printCountingMap.putAll(printCountingMap1);
			}
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("}");
		out.print(" ");
	}
	
	public void print_OrchestrationLanguage_Variable_0(OrchestrationLanguage.Variable element, String outertab, java.io.PrintWriter out, java.util.Map<String, Integer> printCountingMap) {
		int count;
		// DEFINITION PART BEGINS (CsString)
		out.print("name");
		out.print(" ");
		// DEFINITION PART BEGINS (CsString)
		out.print(":");
		out.print(" ");
		// DEFINITION PART BEGINS (PlaceholderInQuotes)
		count = printCountingMap.get("name");
		if (count > 0) {
			Object o = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.VARIABLE__NAME));
			if (o != null) {
				OrchestrationLanguage.resource.ol.IOlTokenResolver resolver = tokenResolverFactory.createTokenResolver("QUOTED_34_34");
				resolver.setOptions(getOptions());
				out.print(resolver.deResolve((Object) o, element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.VARIABLE__NAME), element));
				out.print(" ");
			}
			printCountingMap.put("name", count - 1);
		}
	}
	
	
	public void print_OrchestrationLanguage_Modules(OrchestrationLanguage.Modules element, String outertab, java.io.PrintWriter out) {
		String localtab = outertab;
		// The printCountingMap contains a mapping from feature names to the number of
		// remaining elements that still need to be printed. The map is initialized with
		// the number of elements stored in each structural feature. For lists this is the
		// list size. For non-multiple features it is either 1 (if the feature is set) or
		// 0 (if the feature is null).
		java.util.Map<String, Integer> printCountingMap = new java.util.LinkedHashMap<String, Integer>(1);
		Object temp;
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.MODULES__CONTAINS));
		printCountingMap.put("contains", temp == null ? 0 : ((java.util.Collection<?>) temp).size());
		// print collected hidden tokens
		int count;
		// DEFINITION PART BEGINS (Containment)
		count = printCountingMap.get("contains");
		if (count > 0) {
			java.util.List<?> list = (java.util.List<?>)element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.MODULES__CONTAINS));
			int index  = list.size() - count;
			if (index < 0) {
				index = 0;
			}
			java.util.ListIterator<?> it  = list.listIterator(index);
			while (it.hasNext()) {
				Object o = it.next();
				doPrint((org.eclipse.emf.ecore.EObject) o, out, localtab);
			}
			printCountingMap.put("contains", 0);
		}
	}
	
	
	public void print_OrchestrationLanguage_Module(OrchestrationLanguage.Module element, String outertab, java.io.PrintWriter out) {
		String localtab = outertab;
		// The printCountingMap contains a mapping from feature names to the number of
		// remaining elements that still need to be printed. The map is initialized with
		// the number of elements stored in each structural feature. For lists this is the
		// list size. For non-multiple features it is either 1 (if the feature is set) or
		// 0 (if the feature is null).
		java.util.Map<String, Integer> printCountingMap = new java.util.LinkedHashMap<String, Integer>(3);
		Object temp;
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.MODULE__PROVIDE));
		printCountingMap.put("provide", temp == null ? 0 : ((java.util.Collection<?>) temp).size());
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.MODULE__IMPORTS));
		printCountingMap.put("imports", temp == null ? 0 : ((java.util.Collection<?>) temp).size());
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.MODULE__NAME));
		printCountingMap.put("name", temp == null ? 0 : 1);
		// print collected hidden tokens
		int count;
		// DEFINITION PART BEGINS (CsString)
		out.print("module");
		out.print(" ");
		// DEFINITION PART BEGINS (PlaceholderUsingDefaultToken)
		count = printCountingMap.get("name");
		if (count > 0) {
			Object o = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.MODULE__NAME));
			if (o != null) {
				OrchestrationLanguage.resource.ol.IOlTokenResolver resolver = tokenResolverFactory.createTokenResolver("TEXT");
				resolver.setOptions(getOptions());
				out.print(resolver.deResolve((Object) o, element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.MODULE__NAME), element));
				out.print(" ");
			}
			printCountingMap.put("name", count - 1);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("{");
		out.print(" ");
		// DEFINITION PART BEGINS (Containment)
		count = printCountingMap.get("imports");
		if (count > 0) {
			java.util.List<?> list = (java.util.List<?>)element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.MODULE__IMPORTS));
			int index  = list.size() - count;
			if (index < 0) {
				index = 0;
			}
			java.util.ListIterator<?> it  = list.listIterator(index);
			while (it.hasNext()) {
				Object o = it.next();
				doPrint((org.eclipse.emf.ecore.EObject) o, out, localtab);
			}
			printCountingMap.put("imports", 0);
		}
		// DEFINITION PART BEGINS (Containment)
		count = printCountingMap.get("provide");
		if (count > 0) {
			java.util.List<?> list = (java.util.List<?>)element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.MODULE__PROVIDE));
			int index  = list.size() - count;
			if (index < 0) {
				index = 0;
			}
			java.util.ListIterator<?> it  = list.listIterator(index);
			while (it.hasNext()) {
				Object o = it.next();
				doPrint((org.eclipse.emf.ecore.EObject) o, out, localtab);
			}
			printCountingMap.put("provide", 0);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("}");
		out.print(" ");
	}
	
	
	public void print_OrchestrationLanguage_Import(OrchestrationLanguage.Import element, String outertab, java.io.PrintWriter out) {
		// The printCountingMap contains a mapping from feature names to the number of
		// remaining elements that still need to be printed. The map is initialized with
		// the number of elements stored in each structural feature. For lists this is the
		// list size. For non-multiple features it is either 1 (if the feature is set) or
		// 0 (if the feature is null).
		java.util.Map<String, Integer> printCountingMap = new java.util.LinkedHashMap<String, Integer>(1);
		Object temp;
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.IMPORT__REFERENCES));
		printCountingMap.put("references", temp == null ? 0 : 1);
		// print collected hidden tokens
		int count;
		// DEFINITION PART BEGINS (CsString)
		out.print("import");
		out.print(" ");
		// DEFINITION PART BEGINS (PlaceholderUsingDefaultToken)
		count = printCountingMap.get("references");
		if (count > 0) {
			Object o = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.IMPORT__REFERENCES));
			if (o != null) {
				OrchestrationLanguage.resource.ol.IOlTokenResolver resolver = tokenResolverFactory.createTokenResolver("TEXT");
				resolver.setOptions(getOptions());
				out.print(resolver.deResolve(getReferenceResolverSwitch() == null ? null : getReferenceResolverSwitch().getImportReferencesReferenceResolver().deResolve((OrchestrationLanguage.Module) o, element, (org.eclipse.emf.ecore.EReference) element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.IMPORT__REFERENCES)), element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.IMPORT__REFERENCES), element));
				out.print(" ");
			}
			printCountingMap.put("references", count - 1);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print(";");
		out.print(" ");
	}
	
	
	public void print_OrchestrationLanguage_ExternalServices(OrchestrationLanguage.ExternalServices element, String outertab, java.io.PrintWriter out) {
		String localtab = outertab;
		// The printCountingMap contains a mapping from feature names to the number of
		// remaining elements that still need to be printed. The map is initialized with
		// the number of elements stored in each structural feature. For lists this is the
		// list size. For non-multiple features it is either 1 (if the feature is set) or
		// 0 (if the feature is null).
		java.util.Map<String, Integer> printCountingMap = new java.util.LinkedHashMap<String, Integer>(3);
		Object temp;
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.EXTERNAL_SERVICES__NAME));
		printCountingMap.put("name", temp == null ? 0 : 1);
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.EXTERNAL_SERVICES__LOCATION));
		printCountingMap.put("Location", temp == null ? 0 : 1);
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.EXTERNAL_SERVICES__OPERATIONS));
		printCountingMap.put("operations", temp == null ? 0 : ((java.util.Collection<?>) temp).size());
		// print collected hidden tokens
		int count;
		// DEFINITION PART BEGINS (CsString)
		out.print("service");
		out.print(" ");
		// DEFINITION PART BEGINS (PlaceholderUsingDefaultToken)
		count = printCountingMap.get("name");
		if (count > 0) {
			Object o = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.EXTERNAL_SERVICES__NAME));
			if (o != null) {
				OrchestrationLanguage.resource.ol.IOlTokenResolver resolver = tokenResolverFactory.createTokenResolver("TEXT");
				resolver.setOptions(getOptions());
				out.print(resolver.deResolve((Object) o, element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.EXTERNAL_SERVICES__NAME), element));
				out.print(" ");
			}
			printCountingMap.put("name", count - 1);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("@");
		out.print(" ");
		// DEFINITION PART BEGINS (PlaceholderInQuotes)
		count = printCountingMap.get("Location");
		if (count > 0) {
			Object o = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.EXTERNAL_SERVICES__LOCATION));
			if (o != null) {
				OrchestrationLanguage.resource.ol.IOlTokenResolver resolver = tokenResolverFactory.createTokenResolver("QUOTED_60_62");
				resolver.setOptions(getOptions());
				out.print(resolver.deResolve((Object) o, element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.EXTERNAL_SERVICES__LOCATION), element));
				out.print(" ");
			}
			printCountingMap.put("Location", count - 1);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("{");
		out.print(" ");
		// DEFINITION PART BEGINS (Containment)
		count = printCountingMap.get("operations");
		if (count > 0) {
			java.util.List<?> list = (java.util.List<?>)element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.EXTERNAL_SERVICES__OPERATIONS));
			int index  = list.size() - count;
			if (index < 0) {
				index = 0;
			}
			java.util.ListIterator<?> it  = list.listIterator(index);
			while (it.hasNext()) {
				Object o = it.next();
				doPrint((org.eclipse.emf.ecore.EObject) o, out, localtab);
			}
			printCountingMap.put("operations", 0);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("}");
		out.print(" ");
	}
	
	
	public void print_OrchestrationLanguage_InternalServices(OrchestrationLanguage.InternalServices element, String outertab, java.io.PrintWriter out) {
		String localtab = outertab;
		// The printCountingMap contains a mapping from feature names to the number of
		// remaining elements that still need to be printed. The map is initialized with
		// the number of elements stored in each structural feature. For lists this is the
		// list size. For non-multiple features it is either 1 (if the feature is set) or
		// 0 (if the feature is null).
		java.util.Map<String, Integer> printCountingMap = new java.util.LinkedHashMap<String, Integer>(4);
		Object temp;
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_SERVICES__NAME));
		printCountingMap.put("name", temp == null ? 0 : 1);
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_SERVICES__MAIN));
		printCountingMap.put("main", temp == null ? 0 : 1);
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_SERVICES__USES));
		printCountingMap.put("uses", temp == null ? 0 : ((java.util.Collection<?>) temp).size());
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_SERVICES__INTERNAL_OPERATIONS));
		printCountingMap.put("internalOperations", temp == null ? 0 : ((java.util.Collection<?>) temp).size());
		// print collected hidden tokens
		int count;
		java.io.StringWriter sWriter = null;
		java.io.PrintWriter out1 = null;
		java.util.Map<String, Integer> printCountingMap1 = null;
		// DEFINITION PART BEGINS (Containment)
		count = printCountingMap.get("main");
		if (count > 0) {
			Object o = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_SERVICES__MAIN));
			if (o != null) {
				doPrint((org.eclipse.emf.ecore.EObject) o, out, localtab);
			}
			printCountingMap.put("main", count - 1);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("service");
		out.print(" ");
		// DEFINITION PART BEGINS (PlaceholderUsingDefaultToken)
		count = printCountingMap.get("name");
		if (count > 0) {
			Object o = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_SERVICES__NAME));
			if (o != null) {
				OrchestrationLanguage.resource.ol.IOlTokenResolver resolver = tokenResolverFactory.createTokenResolver("TEXT");
				resolver.setOptions(getOptions());
				out.print(resolver.deResolve((Object) o, element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_SERVICES__NAME), element));
				out.print(" ");
			}
			printCountingMap.put("name", count - 1);
		}
		// DEFINITION PART BEGINS (CompoundDefinition)
		sWriter = new java.io.StringWriter();
		out1 = new java.io.PrintWriter(sWriter);
		printCountingMap1 = new java.util.LinkedHashMap<String, Integer>(printCountingMap);
		print_OrchestrationLanguage_InternalServices_0(element, localtab, out1, printCountingMap1);
		if (printCountingMap.equals(printCountingMap1)) {
			out1.close();
		} else {
			out1.flush();
			out1.close();
			out.print(sWriter.toString());
			printCountingMap.putAll(printCountingMap1);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("{");
		out.print(" ");
		// DEFINITION PART BEGINS (Containment)
		count = printCountingMap.get("internalOperations");
		if (count > 0) {
			java.util.List<?> list = (java.util.List<?>)element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_SERVICES__INTERNAL_OPERATIONS));
			int index  = list.size() - count;
			if (index < 0) {
				index = 0;
			}
			java.util.ListIterator<?> it  = list.listIterator(index);
			while (it.hasNext()) {
				Object o = it.next();
				doPrint((org.eclipse.emf.ecore.EObject) o, out, localtab);
			}
			printCountingMap.put("internalOperations", 0);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("}");
		out.print(" ");
	}
	
	public void print_OrchestrationLanguage_InternalServices_0(OrchestrationLanguage.InternalServices element, String outertab, java.io.PrintWriter out, java.util.Map<String, Integer> printCountingMap) {
		int count;
		// DEFINITION PART BEGINS (CsString)
		out.print("uses");
		out.print(" ");
		// DEFINITION PART BEGINS (PlaceholderUsingDefaultToken)
		count = printCountingMap.get("uses");
		if (count > 0) {
			java.util.List<?> list = (java.util.List<?>)element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_SERVICES__USES));
			int index  = list.size() - count;
			if (index < 0) {
				index = 0;
			}
			java.util.ListIterator<?> it  = list.listIterator(index);
			while (it.hasNext()) {
				Object o = it.next();
				OrchestrationLanguage.resource.ol.IOlTokenResolver resolver = tokenResolverFactory.createTokenResolver("TEXT");
				resolver.setOptions(getOptions());
				out.print(resolver.deResolve(getReferenceResolverSwitch() == null ? null : getReferenceResolverSwitch().getInternalServicesUsesReferenceResolver().deResolve((OrchestrationLanguage.Service) o, element, (org.eclipse.emf.ecore.EReference) element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_SERVICES__USES)), element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_SERVICES__USES), element));
				out.print(" ");
			}
			printCountingMap.put("uses", 0);
		}
	}
	
	
	public void print_OrchestrationLanguage_Main(OrchestrationLanguage.Main element, String outertab, java.io.PrintWriter out) {
		// The printCountingMap contains a mapping from feature names to the number of
		// remaining elements that still need to be printed. The map is initialized with
		// the number of elements stored in each structural feature. For lists this is the
		// list size. For non-multiple features it is either 1 (if the feature is set) or
		// 0 (if the feature is null).
		// print collected hidden tokens
		// DEFINITION PART BEGINS (CsString)
		out.print("main");
		out.print(" ");
	}
	
	
	public void print_OrchestrationLanguage_Process(OrchestrationLanguage.Process element, String outertab, java.io.PrintWriter out) {
		String localtab = outertab;
		// The printCountingMap contains a mapping from feature names to the number of
		// remaining elements that still need to be printed. The map is initialized with
		// the number of elements stored in each structural feature. For lists this is the
		// list size. For non-multiple features it is either 1 (if the feature is set) or
		// 0 (if the feature is null).
		java.util.Map<String, Integer> printCountingMap = new java.util.LinkedHashMap<String, Integer>(2);
		Object temp;
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.PROCESS__NAME));
		printCountingMap.put("name", temp == null ? 0 : 1);
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.PROCESS__PARAMETERS));
		printCountingMap.put("parameters", temp == null ? 0 : ((java.util.Collection<?>) temp).size());
		// print collected hidden tokens
		int count;
		// DEFINITION PART BEGINS (PlaceholderUsingDefaultToken)
		count = printCountingMap.get("name");
		if (count > 0) {
			Object o = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.PROCESS__NAME));
			if (o != null) {
				OrchestrationLanguage.resource.ol.IOlTokenResolver resolver = tokenResolverFactory.createTokenResolver("TEXT");
				resolver.setOptions(getOptions());
				out.print(resolver.deResolve((Object) o, element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.PROCESS__NAME), element));
				out.print(" ");
			}
			printCountingMap.put("name", count - 1);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("(");
		out.print(" ");
		// DEFINITION PART BEGINS (Containment)
		count = printCountingMap.get("parameters");
		if (count > 0) {
			java.util.List<?> list = (java.util.List<?>)element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.PROCESS__PARAMETERS));
			int index  = list.size() - count;
			if (index < 0) {
				index = 0;
			}
			java.util.ListIterator<?> it  = list.listIterator(index);
			while (it.hasNext()) {
				Object o = it.next();
				doPrint((org.eclipse.emf.ecore.EObject) o, out, localtab);
			}
			printCountingMap.put("parameters", 0);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print(");");
		out.print(" ");
	}
	
	
	public void print_OrchestrationLanguage_InternalProcess(OrchestrationLanguage.InternalProcess element, String outertab, java.io.PrintWriter out) {
		String localtab = outertab;
		// The printCountingMap contains a mapping from feature names to the number of
		// remaining elements that still need to be printed. The map is initialized with
		// the number of elements stored in each structural feature. For lists this is the
		// list size. For non-multiple features it is either 1 (if the feature is set) or
		// 0 (if the feature is null).
		java.util.Map<String, Integer> printCountingMap = new java.util.LinkedHashMap<String, Integer>(3);
		Object temp;
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_PROCESS__NAME));
		printCountingMap.put("name", temp == null ? 0 : 1);
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_PROCESS__PARAMETERS));
		printCountingMap.put("parameters", temp == null ? 0 : ((java.util.Collection<?>) temp).size());
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_PROCESS__SEQUENCE));
		printCountingMap.put("sequence", temp == null ? 0 : ((java.util.Collection<?>) temp).size());
		// print collected hidden tokens
		int count;
		// DEFINITION PART BEGINS (PlaceholderUsingDefaultToken)
		count = printCountingMap.get("name");
		if (count > 0) {
			Object o = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_PROCESS__NAME));
			if (o != null) {
				OrchestrationLanguage.resource.ol.IOlTokenResolver resolver = tokenResolverFactory.createTokenResolver("TEXT");
				resolver.setOptions(getOptions());
				out.print(resolver.deResolve((Object) o, element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_PROCESS__NAME), element));
				out.print(" ");
			}
			printCountingMap.put("name", count - 1);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("(");
		out.print(" ");
		// DEFINITION PART BEGINS (Containment)
		count = printCountingMap.get("parameters");
		if (count > 0) {
			java.util.List<?> list = (java.util.List<?>)element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_PROCESS__PARAMETERS));
			int index  = list.size() - count;
			if (index < 0) {
				index = 0;
			}
			java.util.ListIterator<?> it  = list.listIterator(index);
			while (it.hasNext()) {
				Object o = it.next();
				doPrint((org.eclipse.emf.ecore.EObject) o, out, localtab);
			}
			printCountingMap.put("parameters", 0);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print(")");
		out.print(" ");
		// DEFINITION PART BEGINS (CsString)
		out.print("{");
		out.print(" ");
		// DEFINITION PART BEGINS (Containment)
		count = printCountingMap.get("sequence");
		if (count > 0) {
			java.util.List<?> list = (java.util.List<?>)element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.INTERNAL_PROCESS__SEQUENCE));
			int index  = list.size() - count;
			if (index < 0) {
				index = 0;
			}
			java.util.ListIterator<?> it  = list.listIterator(index);
			while (it.hasNext()) {
				Object o = it.next();
				doPrint((org.eclipse.emf.ecore.EObject) o, out, localtab);
			}
			printCountingMap.put("sequence", 0);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("}");
		out.print(" ");
	}
	
	
	public void print_OrchestrationLanguage_Call(OrchestrationLanguage.Call element, String outertab, java.io.PrintWriter out) {
		// The printCountingMap contains a mapping from feature names to the number of
		// remaining elements that still need to be printed. The map is initialized with
		// the number of elements stored in each structural feature. For lists this is the
		// list size. For non-multiple features it is either 1 (if the feature is set) or
		// 0 (if the feature is null).
		java.util.Map<String, Integer> printCountingMap = new java.util.LinkedHashMap<String, Integer>(2);
		Object temp;
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.CALL__INPUT));
		printCountingMap.put("input", temp == null ? 0 : ((java.util.Collection<?>) temp).size());
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.CALL__TARGET));
		printCountingMap.put("target", temp == null ? 0 : 1);
		// print collected hidden tokens
		int count;
		// DEFINITION PART BEGINS (PlaceholderUsingDefaultToken)
		count = printCountingMap.get("target");
		if (count > 0) {
			Object o = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.CALL__TARGET));
			if (o != null) {
				OrchestrationLanguage.resource.ol.IOlTokenResolver resolver = tokenResolverFactory.createTokenResolver("TEXT");
				resolver.setOptions(getOptions());
				out.print(resolver.deResolve(getReferenceResolverSwitch() == null ? null : getReferenceResolverSwitch().getCallTargetReferenceResolver().deResolve((OrchestrationLanguage.Process) o, element, (org.eclipse.emf.ecore.EReference) element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.CALL__TARGET)), element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.CALL__TARGET), element));
				out.print(" ");
			}
			printCountingMap.put("target", count - 1);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("(");
		out.print(" ");
		// DEFINITION PART BEGINS (PlaceholderUsingDefaultToken)
		count = printCountingMap.get("input");
		if (count > 0) {
			Object o = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.CALL__INPUT));
			java.util.List<?> list = (java.util.List<?>) o;
			int index = list.size() - count;
			if (index >= 0) {
				o = list.get(index);
			} else {
				o = null;
			}
			if (o != null) {
				OrchestrationLanguage.resource.ol.IOlTokenResolver resolver = tokenResolverFactory.createTokenResolver("TEXT");
				resolver.setOptions(getOptions());
				out.print(resolver.deResolve(getReferenceResolverSwitch() == null ? null : getReferenceResolverSwitch().getCallInputReferenceResolver().deResolve((OrchestrationLanguage.Argument) o, element, (org.eclipse.emf.ecore.EReference) element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.CALL__INPUT)), element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.CALL__INPUT), element));
				out.print(" ");
			}
			printCountingMap.put("input", count - 1);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print(");");
		out.print(" ");
	}
	
	
	public void print_OrchestrationLanguage_Argument(OrchestrationLanguage.Argument element, String outertab, java.io.PrintWriter out) {
		String localtab = outertab;
		// The printCountingMap contains a mapping from feature names to the number of
		// remaining elements that still need to be printed. The map is initialized with
		// the number of elements stored in each structural feature. For lists this is the
		// list size. For non-multiple features it is either 1 (if the feature is set) or
		// 0 (if the feature is null).
		java.util.Map<String, Integer> printCountingMap = new java.util.LinkedHashMap<String, Integer>(2);
		Object temp;
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.ARGUMENT__ASSIGN_FROM));
		printCountingMap.put("assignFrom", temp == null ? 0 : 1);
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.ARGUMENT__ASSIGN_TO));
		printCountingMap.put("assignTo", temp == null ? 0 : 1);
		// print collected hidden tokens
		boolean iterate = true;
		java.io.StringWriter sWriter = null;
		java.io.PrintWriter out1 = null;
		java.util.Map<String, Integer> printCountingMap1 = null;
		// DEFINITION PART BEGINS (CompoundDefinition)
		iterate = true;
		while (iterate) {
			sWriter = new java.io.StringWriter();
			out1 = new java.io.PrintWriter(sWriter);
			printCountingMap1 = new java.util.LinkedHashMap<String, Integer>(printCountingMap);
			print_OrchestrationLanguage_Argument_0(element, localtab, out1, printCountingMap1);
			if (printCountingMap.equals(printCountingMap1)) {
				iterate = false;
				out1.close();
			} else {
				out1.flush();
				out1.close();
				out.print(sWriter.toString());
				printCountingMap.putAll(printCountingMap1);
			}
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("}");
		out.print(" ");
	}
	
	public void print_OrchestrationLanguage_Argument_0(OrchestrationLanguage.Argument element, String outertab, java.io.PrintWriter out, java.util.Map<String, Integer> printCountingMap) {
		String localtab = outertab;
		int count;
		java.io.StringWriter sWriter = null;
		java.io.PrintWriter out1 = null;
		java.util.Map<String, Integer> printCountingMap1 = null;
		// DEFINITION PART BEGINS (PlaceholderUsingDefaultToken)
		count = printCountingMap.get("assignTo");
		if (count > 0) {
			Object o = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.ARGUMENT__ASSIGN_TO));
			if (o != null) {
				OrchestrationLanguage.resource.ol.IOlTokenResolver resolver = tokenResolverFactory.createTokenResolver("TEXT");
				resolver.setOptions(getOptions());
				out.print(resolver.deResolve(getReferenceResolverSwitch() == null ? null : getReferenceResolverSwitch().getArgumentAssignToReferenceResolver().deResolve((OrchestrationLanguage.Variable) o, element, (org.eclipse.emf.ecore.EReference) element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.ARGUMENT__ASSIGN_TO)), element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.ARGUMENT__ASSIGN_TO), element));
				out.print(" ");
			}
			printCountingMap.put("assignTo", count - 1);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("=");
		out.print(" ");
		// DEFINITION PART BEGINS (PlaceholderUsingDefaultToken)
		count = printCountingMap.get("assignFrom");
		if (count > 0) {
			Object o = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.ARGUMENT__ASSIGN_FROM));
			if (o != null) {
				OrchestrationLanguage.resource.ol.IOlTokenResolver resolver = tokenResolverFactory.createTokenResolver("TEXT");
				resolver.setOptions(getOptions());
				out.print(resolver.deResolve(getReferenceResolverSwitch() == null ? null : getReferenceResolverSwitch().getArgumentAssignFromReferenceResolver().deResolve((OrchestrationLanguage.Variable) o, element, (org.eclipse.emf.ecore.EReference) element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.ARGUMENT__ASSIGN_FROM)), element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.ARGUMENT__ASSIGN_FROM), element));
				out.print(" ");
			}
			printCountingMap.put("assignFrom", count - 1);
		}
		// DEFINITION PART BEGINS (CompoundDefinition)
		sWriter = new java.io.StringWriter();
		out1 = new java.io.PrintWriter(sWriter);
		printCountingMap1 = new java.util.LinkedHashMap<String, Integer>(printCountingMap);
		print_OrchestrationLanguage_Argument_0_0(element, localtab, out1, printCountingMap1);
		if (printCountingMap.equals(printCountingMap1)) {
			out1.close();
		} else {
			out1.flush();
			out1.close();
			out.print(sWriter.toString());
			printCountingMap.putAll(printCountingMap1);
		}
	}
	
	public void print_OrchestrationLanguage_Argument_0_0(OrchestrationLanguage.Argument element, String outertab, java.io.PrintWriter out, java.util.Map<String, Integer> printCountingMap) {
		// DEFINITION PART BEGINS (CsString)
		out.print(",");
		out.print(" ");
	}
	
	
	public void print_OrchestrationLanguage_If(OrchestrationLanguage.If element, String outertab, java.io.PrintWriter out) {
		String localtab = outertab;
		// The printCountingMap contains a mapping from feature names to the number of
		// remaining elements that still need to be printed. The map is initialized with
		// the number of elements stored in each structural feature. For lists this is the
		// list size. For non-multiple features it is either 1 (if the feature is set) or
		// 0 (if the feature is null).
		java.util.Map<String, Integer> printCountingMap = new java.util.LinkedHashMap<String, Integer>(3);
		Object temp;
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.IF__ELSE));
		printCountingMap.put("else", temp == null ? 0 : 1);
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.IF__CONDITION));
		printCountingMap.put("condition", temp == null ? 0 : 1);
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.IF__IF_EXECUTE));
		printCountingMap.put("ifExecute", temp == null ? 0 : ((java.util.Collection<?>) temp).size());
		// print collected hidden tokens
		int count;
		// DEFINITION PART BEGINS (CsString)
		out.print("if");
		out.print(" ");
		// DEFINITION PART BEGINS (CsString)
		out.print("(");
		out.print(" ");
		// DEFINITION PART BEGINS (PlaceholderUsingDefaultToken)
		count = printCountingMap.get("condition");
		if (count > 0) {
			Object o = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.IF__CONDITION));
			if (o != null) {
				OrchestrationLanguage.resource.ol.IOlTokenResolver resolver = tokenResolverFactory.createTokenResolver("TEXT");
				resolver.setOptions(getOptions());
				out.print(resolver.deResolve((Object) o, element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.IF__CONDITION), element));
				out.print(" ");
			}
			printCountingMap.put("condition", count - 1);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print(")");
		out.print(" ");
		// DEFINITION PART BEGINS (CsString)
		out.print("{");
		out.print(" ");
		// DEFINITION PART BEGINS (Containment)
		count = printCountingMap.get("ifExecute");
		if (count > 0) {
			java.util.List<?> list = (java.util.List<?>)element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.IF__IF_EXECUTE));
			int index  = list.size() - count;
			if (index < 0) {
				index = 0;
			}
			java.util.ListIterator<?> it  = list.listIterator(index);
			while (it.hasNext()) {
				Object o = it.next();
				doPrint((org.eclipse.emf.ecore.EObject) o, out, localtab);
			}
			printCountingMap.put("ifExecute", 0);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("}");
		out.print(" ");
		// DEFINITION PART BEGINS (PlaceholderUsingDefaultToken)
		count = printCountingMap.get("else");
		if (count > 0) {
			Object o = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.IF__ELSE));
			if (o != null) {
				OrchestrationLanguage.resource.ol.IOlTokenResolver resolver = tokenResolverFactory.createTokenResolver("TEXT");
				resolver.setOptions(getOptions());
				out.print(resolver.deResolve(getReferenceResolverSwitch() == null ? null : getReferenceResolverSwitch().getIfElseReferenceResolver().deResolve((OrchestrationLanguage.Else) o, element, (org.eclipse.emf.ecore.EReference) element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.IF__ELSE)), element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.IF__ELSE), element));
				out.print(" ");
			}
			printCountingMap.put("else", count - 1);
		}
	}
	
	
	public void print_OrchestrationLanguage_Else(OrchestrationLanguage.Else element, String outertab, java.io.PrintWriter out) {
		String localtab = outertab;
		// The printCountingMap contains a mapping from feature names to the number of
		// remaining elements that still need to be printed. The map is initialized with
		// the number of elements stored in each structural feature. For lists this is the
		// list size. For non-multiple features it is either 1 (if the feature is set) or
		// 0 (if the feature is null).
		java.util.Map<String, Integer> printCountingMap = new java.util.LinkedHashMap<String, Integer>(1);
		Object temp;
		temp = element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.ELSE__ELSE_EXECUTE));
		printCountingMap.put("elseExecute", temp == null ? 0 : ((java.util.Collection<?>) temp).size());
		// print collected hidden tokens
		int count;
		// DEFINITION PART BEGINS (CsString)
		out.print("else");
		out.print(" ");
		// DEFINITION PART BEGINS (CsString)
		out.print("{");
		out.print(" ");
		// DEFINITION PART BEGINS (Containment)
		count = printCountingMap.get("elseExecute");
		if (count > 0) {
			java.util.List<?> list = (java.util.List<?>)element.eGet(element.eClass().getEStructuralFeature(OrchestrationLanguage.OrchestrationLanguagePackage.ELSE__ELSE_EXECUTE));
			int index  = list.size() - count;
			if (index < 0) {
				index = 0;
			}
			java.util.ListIterator<?> it  = list.listIterator(index);
			while (it.hasNext()) {
				Object o = it.next();
				doPrint((org.eclipse.emf.ecore.EObject) o, out, localtab);
			}
			printCountingMap.put("elseExecute", 0);
		}
		// DEFINITION PART BEGINS (CsString)
		out.print("}");
		out.print(" ");
	}
	
	
}
